import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
import Page from '@/components/mixins/page.js';
export default {
	mixins: [Page, MescrollMixin],
	data() {
		return {
			downOption: {
				// 首次自动执行
				auto: false,
			},
			upOption: {
				// 首次自动执行
				auto: false,
				// 每页数据的数量; 默认15
				page: {
					size: 15
				},
				// 数量要大于5条才显示无更多数据
				noMoreSize: 5,
				// 空布局
				empty: {
					tip: '~没有数据~'
				},
				// 距底部多远时,触发upCallback
				offset: 300,
			}
		}
	},
	methods: {
		__loadPage: async function(param) {
			let size = 0;
			try {
				let page = await this.loadPage(param);
				size = page.data.length;
				this.datas = this.append ? this.datas.concat(page.data) : page.data;
				this.param = page.param;
			} catch (e) {
				console.log(e)
			} finally {
				this.initialize = true;
				this.loading = false;
				this.mescroll.endSuccess(size, this.hasMore);
			}
			return true;
		},
		downCallback: function() {
			this.reset();
			setTimeout(() => {
				this.mescroll.resetUpScroll()
			}, 100)
		},
		upCallback: function() {
			this.nextPage()
		},
		// upCallback: function(page) {
		// 	console.log("----------上滑----------------");
		// 	this.nextPage()
		// },
	}
}